package com.woniuxy.reservation.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.reservation.client.param.SearchReservationByConditionParam;
import com.woniuxy.reservation.client.reservationclient.ReservationQueryClient;
import com.woniuxy.reservation.client.result.ReservationClientDto;
import com.woniuxy.reservation.service.ReservationService;
import com.woniuxy.reservation.service.servicedto.ReservationServiceDto;
import com.woniuxy.reservation.service.serviceparam.SearchReservationByConditionServiceParam;
import common.WoniuPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

@RestController
public class ReservationQueryClientApiImpl implements ReservationQueryClient {
    @Autowired
    private ReservationService reservationService;
    @Override
    @Log("根据条件查询预约")
    public Result searchReservationByCondition(SearchReservationByConditionParam param) {
        SearchReservationByConditionServiceParam searchReservationByConditionServiceParam = BeanUtil.toBean(param, SearchReservationByConditionServiceParam.class);
        WoniuPage<ReservationServiceDto> woniuPage = reservationService.searchReservationByCondition(searchReservationByConditionServiceParam);
        WoniuPage<ReservationClientDto> page = BeanUtil.toBean(woniuPage, WoniuPage.class);
        return Result.success(page);
    }
}
